<template>
  <el-container class="electronicSignature">
    <el-main class="mainDetails">
      <SearchPanel title="查询结果">
        <div class="searchPanel-content">
          <FinalAccountsTable :tableData="getFinalAccountsList" :columns="checkColumns" :isCheck="false"
            :isSortNum="true" @handleSelectionChange="handleSelectionChange" :colOptionEnum="getdicLists">
            <template #prjName="{ scope }">
              <span @click="skipFinalAccounts(scope)" style="color:rgb(51, 170, 255);cursor: pointer;">
                {{ scope.prjName }}
              </span>
            </template>
          </FinalAccountsTable>
          <pagination v-if="getCount > 10" :total="getCount" :page.sync="pageParam.pageNum"
            :limit.sync="pageParam.pageSize" @pagination="doSearch" />
        </div>
        <el-dialog class="pms-zr-dialog" ref="contractCode" :close-on-click-modal="false" v-dialogDrag
          :append-to-body="true" :modal-append-to-body="true" :modal="true" :visible.sync="showHistoryDialog"
          title="操作历史" width="70%">
          <FinalAccountsTable :tableData="getFinalAccountsHistotyList" :columns="checkColumnsHistory"
            :isSortNum="true" />
        </el-dialog>
      </SearchPanel>
    </el-main>
  </el-container>
</template>

<script>
import FinalAccountsTable from '@/views/finalAccounts/components/finalAccountsTable.vue'
import SearchPanel from '@/components/basic/SearchPanel'
import SysConst from '@/common/const'
import { checkColumns, checkColumnsHistory } from '@/views/finalAccounts/setting'
import { mapGetters, mapActions } from 'vuex'
export default {
  name: 'FinalAccountDetail',
  components: {
    SearchPanel,
    FinalAccountsTable
  },
  computed: {
    ...mapGetters('finalAccounts', ['getCount', 'getFinalAccountsList', 'getFinalAccountsHistotyList', 'getdicLists'])
  },
  data() {
    return {
      checkColumns,
      checkColumnsHistory,
      pageParam: {
        pageSize: SysConst.PAGESIZE, // 每页显示val条
        pageNum: SysConst.CURRENT_PAGE, // 当前页
        total: 0// 总数
      },
      multipleSelection: [], // 选中项列表
      showHistoryDialog: false,
    }
  },
  methods: {
    ...mapActions('finalAccounts', ['getSearchList', 'getSearchHistoryList']),
    doSearch(item) {
      const params = {
        pageNum: item?.page || SysConst.CURRENT_PAGE,
        pageSize: item?.limit || SysConst.PAGESIZE,
      }
      this.getSearchList(params)
    },
    handleSelectionChange(data) {
      this.multipleSelection = data;
    },
    handleClick(type) {
      if (this.multipleSelection.length === 0) {
        this.$message.warning('请勾选数据后操作')
        return
      }
      if (['handleprojectHistory'].includes(type) && this.multipleSelection.length > 1) {
        this.$message.warning('当前仅支持单条数据操作')
        return
      }
      this[type]()
    },
    handleprojectHistory() {
      this.showHistoryDialog = true;
      this.getSearchHistoryList()
    },
    // 送审
    skipFinalAccounts(row) {
      window.open(`${process.env.VUE_APP_ZHONGRUAN_URL}handleFinalAccounts?prjId=${row.prjId}&type=1`, '_blank')
    }
  }
}

</script>
<style lang="scss" scoped>
.electronicSignature {
  padding: 0 45px;
  width: 100%;
}
</style>
